package com.imcode;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 反序列化
 */
public class ObjectInputStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectInputStream in =
                new ObjectInputStream(new FileInputStream("file/student.data"));

        Student student = (Student) in.readObject();
        System.out.println(student.getName());//张三
        System.out.println(student.getSex());//男
        System.out.println(student.getAge());//0
        System.out.println(student.getTeacher().getName());//张老师
        in.close();
    }
}
